package timing.ukulele.third.controller.msg;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import timing.ukulele.common.data.ResponseData;
import timing.ukulele.data.third.data.msg.MessageNoticeItemDTO;
import timing.ukulele.data.third.view.msg.MessageNoticeItemVO;
import timing.ukulele.third.service.msg.MessageNoticeItemService;

import java.util.List;

/**
 * 消息通知事项管理接口
 *
 * @author zh
 */
@RestController
@RequestMapping("/msg/messageNoticeItem")
@Slf4j
public class MessageNoticeItemController {

    private final MessageNoticeItemService service;

    public MessageNoticeItemController(MessageNoticeItemService service) {
        this.service = service;
    }

    /**
     * /msg/messageNoticeItem/addMessageNoticeItem
     * @param dto
     * @return
     */
    @PostMapping("/add")
    @Operation(summary = "新增消息通知事项")
    public ResponseData<Boolean> addMessageNoticeItem(@RequestBody MessageNoticeItemDTO dto) {
        return ResponseData.success(service.addMessageNoticeItem(dto));
    }

    /**
     * /msg/messageNoticeItem/updateMessageNoticeItem
     * @param dto
     * @return
     */
    @PutMapping("/update")
    @Operation(summary = "修改消息通知事项")
    public ResponseData<Boolean> updateMessageNoticeItem(@RequestBody MessageNoticeItemDTO dto) {
        return ResponseData.success(service.updateMessageNoticeItem(dto));
    }

    /**
     * /msg/messageNoticeItem/deleteMessageNoticeItem
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    @Operation(summary = "删除消息通知事项")
    public ResponseData<Boolean> deleteMessageNoticeItem(@RequestParam("id") Long id) {
        return ResponseData.success(service.deleteMessageNoticeItem(id));
    }

    /**
     * /msg/messageNoticeItem/page
     * @param dto
     * @return
     */
    @GetMapping("/page")
    @Operation(summary = "消息通知事项分页列表")
    public ResponseData<IPage<MessageNoticeItemVO>> page(MessageNoticeItemDTO dto) {
        return ResponseData.success(service.pageList(dto));
    }

    /**
     * /msg/messageNoticeItem/getByServerId
     * @param serverId
     * @return
     */
    @GetMapping("/getByServerId")
    @Operation(summary = "根据服务ID获取列表")
    public ResponseData<List<MessageNoticeItemVO>> getByServerId(Long serverId) {
        return ResponseData.success(service.getByServerId(serverId));
    }

}
